#include "form.h"
#include "ui_form.h"

Form::Form(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Form)
{
    ui->setupUi(this);
    line1=new QPropertyAnimation(ui->label_3,"geometry",this);
    line1->setDuration(1500);
    line1->setKeyValueAt(0,QRect(0,15,2,0));
    line1->setKeyValueAt(0.5,QRect(0,0,2,17));
    line1->setKeyValueAt(1,QRect(0,15,2,0));
    line1->setLoopCount(-1);
    line1->start() ;
    line2=new QPropertyAnimation(ui->label,"geometry",this);
    line2->setDuration(1600);
    line2->setKeyValueAt(0,QRect(7,15,2,0));
    line2->setKeyValueAt(0.5,QRect(7,0,2,17));
    line2->setKeyValueAt(1,QRect(7,15,2,0));
    line2->setLoopCount(-1);
    line2->start() ;
    line3=new QPropertyAnimation(ui->label_4,"geometry",this);
    line3->setDuration(1700);
    line3->setKeyValueAt(0,QRect(14,15,2,0));
    line3->setKeyValueAt(0.5,QRect(14,0,2,17));
    line3->setKeyValueAt(1,QRect(14,15,2,0));
    line3->setLoopCount(-1);
    line3->start() ;
    line4=new QPropertyAnimation(ui->label_2,"geometry",this);
    line4->setDuration(1800);
    line4->setKeyValueAt(0,QRect(21,15,2,0));
    line4->setKeyValueAt(0.5,QRect(21,0,2,17));
    line4->setKeyValueAt(1,QRect(21,15,2,0));
    line4->setLoopCount(-1);
    line4->start() ;
    ui->linbox->hide();
}

void Form::Seticonandtext(const QString &icon, const QString &text,int id)
{
    ui->btcolon->setPixmap(QPixmap(icon));
    ui->bttext->setText(text);
    this->pageid=id;
}

int Form::getid() const
{
    return pageid;
}

void Form::showanimt()
{
    ui->linbox->show();
}

void Form::changebackground()
{
    ui->btstyle->setStyleSheet("#btstyle:hover{background-color:#D8D8D8;}");
}
Form::~Form()
{
    delete ui;
}

void Form::mousePressEvent(QMouseEvent *event)
{
    //鼠标按下改变背景颜色
    ui->btstyle->setStyleSheet("#btstyle{background-color:rgb(30,206,154);}");
    //鼠标按下跳转对应的页
    emit btClick(pageid);
}
